/**
 * 
 */
	function loaddata(){
		var allFlag = $("#allFlag").val();
		var pno = $("#pagenum").val();
		var month=$("#month").val();
		var bonus=$("#bonus").val();
		var ope_fk=$("#ope_id_Ary").val();
		var score = $("#score").val();
		var emp_id = $("#emp_id").val();
		var grade = $("#grade").val();
		var classtype = $("#classtype").val();
		var url = pms_url + "ary/performance/list";
		var params = {month:month,bonus:bonus,ope_fk:ope_fk,score:score,emp_id:emp_id,pno:pno,allFlag:allFlag,grade:grade,classtype:classtype};
		var obj = load(url,params);//发送请求去服务端ope_fk数据	
		var lcm = obj.performance;
		$("#performancelist").find("tbody").html("");
		$.each(lcm, function(index, p) {
		var tr ="<tr role='row'>"+
		"<td>"+(index+1)+"</td>"+
		"<td>"+p.label+"</td>"+
		"<td>"+p.emp_id+"</td>"+
		"<td>"+p.emp_name+"</td>"+
		"<td>"+p.gender+"</td>"+
		"<td>"+((p.classtype==null)?"":p.classtype)+"</td>"+
		"<td>"+((p.grade==null)?"":p.grade)+"</td>"+
		"<td>"+((p.bonus==null)?"0":p.bonus)+"</td>"+
		"<td>"+((p.attendance==null)?"0":p.attendance)+"</td>"+
		"<td>"+((p.worktype==null)?"0":p.worktype)+"</td>"+
		"<td>"+((p.workability==null)?"0":p.workability)+"</td>"+
		"<td>"+((p.compatibility==null)?"0":p.compatibility)+"</td>"+
		"<td>"+((p.score==null)?"0":p.score)+"</td></tr>";
		$("#performancelist").find("tbody").append(tr);
	 });
		
		//加载平均奖金
		
		var aurl = pms_url + "ary/performance/getAverageBouns";
		var param = {month:month,ope_fk:ope_fk,bonus:bonus,score:score,emp_id:emp_id,grade:grade,classtype:classtype};
		$.ajax({  
	        type : "post",  
	        url : aurl,  
	        data : param,
	        dataType : "json", 
	        async : false,  //同步
	        success : function(data){  
	           data = eval(data);  
		   		if (data.err_msg=="success") {
		   			$("#average").html(data.result);
				}
				else {
					alert("error");
				}
	        }  
	    });
		
		var aurl = pms_url + "ary/performance/getAllBonuses";
		var param = {month:month,ope_fk:ope_fk,bonus:bonus,score:score,emp_id:emp_id,grade:grade,classtype:classtype};
		$.ajax({  
	        type : "post",  
	        url : aurl,  
	        data : param,
	        dataType : "json", 
	        async : false,  //同步
	        success : function(data){  
	           data = eval(data);  
		   		if (data.err_msg=="success") {
		   			$("#bonusPool").html(data.result);
				}
				else {
					alert("error");
				}
	        }  
	    });
		
		
		var aurl = pms_url + "ary/performance/getActualBonus";
		var param = {month:month,ope_fk:ope_fk,bonus:bonus,score:score,emp_id:emp_id,grade:grade,classtype:classtype};
		$.ajax({  
	        type : "post",  
	        url : aurl,  
	        data : param,
	        dataType : "json", 
	        async : false,  //同步
	        success : function(data){  
	           data = eval(data);  
		   		if (data.err_msg=="success") {
		   			$("#actualBonus").html(data.result);
				}
				else {
					alert("error");
				}
	        }  
	    });
	}


	function update(){

		var url = pms_url + "ary/performance/syschron"; 
		var param = {};
		$.ajax({  
	        type : "post",  
	        url : url,  
	        dataType: "json", 
	        data : param, 
	        async : false,  //同步
	        beforeSend: function () {  
        	        // 禁用按钮防止重复提交  
        	        $("#btnSyschron").attr({ disabled: "disabled" });
        	        MaskUtil.mask("正在更新中..."); 
        	        
        	    },  
	        success : function(data){ 
	    			if(data.err_msg=="success"){
	    				MaskUtil.unmask();
	    				alert("更新数据成功！");
	    		}
	        	},
	        complete: function () {  
	            	$("#btnSyschron").removeAttr("disabled");  
	            	MaskUtil.unmask();   
	            },  
        	error: function (data) {  
        	        console.info("error: " + data.responseText);  
        	    } 
	        });
	
	}
	
	
	
	$(function () {
		
		
		loaddata();
		//TableDatatablesEditable.init();
		
		
		//查询
		$('#btnSearch').on('click', function () {
			$("#pagenum").val(1);
			loaddata();
			
		});
		
		//重置
		$("#btnReset").on('click', function () {
			$("#searchform1 input").val("");
			$("#searchform1 select").val("");
			$("#searchform2 input").val("");
			$("#searchform2 select").val("");
		});	
	
		//更新
		$("#btnSyschron").on('click', function () {
			update();
			loaddata();
		});	
		
		
		//导出
		$("#btnExport").on('click', function () {
			$("#performancelist").tableExport({
			    headings: true, 
			    footers: true, 
			    formats: ["xls"],
			    fileName: "data",
			    bootstrap: true,
			    position: "bottom",
			    ignoreRows: null,
			    ignoreCols: null
			});   

		});	
		
	});
	
	
